/*
 *  Copyright (C) 2010 Glauco
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.balisunrise.swing.components.panel;

import java.awt.Dimension;
import javax.swing.JPanel;
import org.balisunrise.swing.components.focusManager.FocusManagers;
import org.balisunrise.swing.components.focusManager.JPanelFocusManager;
import org.balisunrise.swing.components.panel.layouts.SearchLayoutBuilder;

/**
 *
 * @author Glauco
 */
public class SearchPanel extends JPanel{

    private JPanel filterPanel;
    private JPanel gridPanel;
    private JPanel actionPanel;

    private SearchLayoutBuilder layoutBuilder;

    private JPanelFocusManager focusManager;

    public JPanel getActionPanel() {
        return actionPanel;
    }

    public void setActionPanel(JPanel actionPanel) {
        this.actionPanel = actionPanel;
        createLayout();
    }

    public JPanel getFilterPanel() {
        return filterPanel;
    }

    public void setFilterPanel(JPanel filterPanel) {
        this.filterPanel = filterPanel;
        createLayout();
    }

    public JPanel getGridPanel() {
        return gridPanel;
    }

    public void setGridPanel(JPanel gridPanel) {
        this.gridPanel = gridPanel;
        createLayout();
    }

    public SearchPanel(JPanel filterPanel, JPanel gridPanel, JPanel actionPanel,
            SearchLayoutBuilder layoutBuilder) {

        super();
        
        this.filterPanel = filterPanel;
        this.gridPanel = gridPanel;
        this.actionPanel = actionPanel;

        this.layoutBuilder = layoutBuilder;

        setMinimumSize(new Dimension(10, 315));

        createLayout();

        focusManager = new JPanelFocusManager(this);
        FocusManagers.getInstance().addFocusManager(focusManager);
    }

    public JPanelFocusManager getFocusManager() {
        return focusManager;
    }

    private void createLayout(){

        layoutBuilder.setFilterPanel(filterPanel);
        layoutBuilder.setGridPanel(gridPanel);
        layoutBuilder.setActionPanel(actionPanel);
        layoutBuilder.buildLayout(this);

    }

}
